<?php
namespace BoxApi\Controller;

use Think\Controller;

class KindeditorController extends CommonController {
	/****Kindeditor图片上传***/

	public function uploadJson() {
		$param = array('type' => 'return');
		$data = hook("Upload/Index/upload", $param);
		header('Content-type: text/html; charset=UTF-8');
		if ($data['error'] == 0) {
			echo json_encode(array('error' => 0, 'url' => $data['data']['file_url']));
		} else {
			echo json_encode(array('error' => $data['error'], 'msg' => $data['msg']));
		}
		exit;

	}

	function upload() {
		$param = array('type' => 'return');
		$data = hook("Upload/Index/upload", $param);
		header('Content-type: text/html; charset=UTF-8');
		if ($data['error'] == 0) {
			echo $data['data']['file_url'] . "?x-oss-process=image/resize,m_lfit,w_1000,limit_1";
		} else {
			echo "error|" . $data['msg'];
		}
		exit;
	}

}

?>